<?php

class ImportCommand extends CConsoleCommand{
	
	public function run( $args ) {
		/* $args[0] => feeder; $args[1] => league; $args[2] => bet */
		
		Yii::import("application.importers.*", true);
		
		/* Not enough params */
		if( count( $args ) < 3 ){
			echo "\n\nError executing command. Example: yiic importer <FEEDER_ID> <LEAGUE_ID> <BET_TYPE_ID>\n\n\n";
			exit;
		}
		
		$importer = null;
		switch( $args[0] ){
			case Importer::FEEDER_NAME_WH:
				$importer = new WilliamHillImporter();
				break;
			default:
				echo "\n\nError executing command: '$args[0]' not recognized as feeder name.\n\n\n";
				break;
		}
		
		if( $importer ){
			$importer->prepareImportation( $args[0], $args[1], $args[2] );
			$importer->runImportation();
		}
	}
	
}
